const {getHeader} = require('./duozhuayu');
var http = require('http');
var url = require("url");
var querystring = require("querystring");

http.createServer(function (request, response) {

    // 发送 HTTP 头部 
    // HTTP 状态值: 200 : OK
    // 内容类型: text/plain
    response.writeHead(200, {'Content-Type': 'text/plain'});
    var arg = url.parse(request.url).query;
    var params = querystring.parse(arg);
    var userid = params.userid;
    // 发送响应数据 "Hello World"
    var headers = getHeader(userid);
    var headerString = JSON.stringify(headers);
    response.end(headerString);
}).listen(8888,'0.0.0.0');

// 终端打印如下信息
console.log('Server running at http://127.0.0.1:8888/');
